package com.config.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.config.common.Result;
import com.config.entity.Operation;
import com.config.service.OperationService;
import com.config.vo.OperationVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  运行环境前端控制器
 * </p>
 *
 * @author Lu
 * @since 2021-02-04
 */
@Api (tags ="运行环境设置页面接口")
@RestController
@RequestMapping("/config/operation")
public class OperationController {

	@Autowired
	OperationService operationService;

	@ApiOperation ("获取所有信息（分页）")
	@GetMapping ("/operationPageAll")
	public Result selectpageAll(Integer current, Integer size) {
		OperationVo userVo = new OperationVo();
		IPage<Operation> page = new Page<>(current, size);
		IPage<Operation> page1 = operationService.page(page, null);
		userVo.setCurrent(current);
		userVo.setSize(size);
		userVo.setTotal(page.getTotal());
		userVo.setOperationList(page.getRecords());
		return Result.succ(page1);
	}

	@ApiOperation ("修改列表数据")
	@PutMapping ("/opupd")
	public Result upopChoose0(@RequestBody Operation operation) {
		boolean update = operationService.updateById(operation);
		if (update) {
			return Result.succ(operation);
		} else {
			return Result.fail("修改失败");
		}
	}
}

